package company.sougou;

import java.util.Arrays;

public class Sou1 {

    public static void main(String[] args) {
        Sou1 sou1 = new Sou1();
        System.out.println(sou1.numberofprize(4, 4, 2));
    }

    public int numberofprize(int a, int b, int c) {
        // write code here
        int[] array = new int[3];
        array[0] = a;
        array[1] = b;
        array[2] = c;
        Arrays.sort(array);
        int count = array[0];
        array[0] -= count;
        array[1] -= count;
        array[2] -= count;

        while (true) {
            if (array[1] == array[2]) {
                return array[1] / 2 + count;
            } else if (array[1] >= 1 && array[2] >= 3) {
                array[1] -= 1;
                array[2] -= 3;
                count++;
                if (array[1] > array[2])
                    swap(array,1,2);
            } else if (array[1] == 0 && array[2] >= 5) {
                array[2] -= 5;
                count++;
            } else
                break;
        }
        return count;
    }

    private void swap(int[] array, int i, int j) {
        int tmp = array[i];
        array[i] = array[j];
        array[j] = tmp;
    }

}
